﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Remember.WPF.Views;

namespace Remember.WPF.Pages
{
    /// <summary>
    /// Interaction logic for LoginPage.xaml
    /// </summary>
    public partial class LoginPage : Page
    {
        public LoginPage()
        {
            InitializeComponent();

            this.loginControl1.OnStart += new EventHandler(loginControl1_OnStart);
            this.loginControl1.OnAddLogin += new EventHandler(loginControl1_OnAddLogin);
        }

        void loginControl1_OnAddLogin(object sender, EventArgs e)
        {
            TTS speaker = new TTS();
            speaker.Show();

            return;

            LoginControl loginControl1 = sender as LoginControl;

            if (loginControl1 != null)
            {
                var loginAdd = new LoginAdd();
                loginAdd.OnClose += new EventHandler((a, b) => { this.childWindow.Close(); loginControl1.Build(); });

                OpenLoingAddWindow( loginAdd);
            }

        }

        void loginControl1_OnStart(object sender, EventArgs e)
        {
            if ( MainWindow.CurrentWindow != null )
            {
                MainWindow.CurrentWindow.NavigationService.Navigate(new Uri(MainWindow.HomePageUrl, System.UriKind.Relative));
            }
        }


        void OpenLoingAddWindow( LoginAdd loginAdd)
        {

            childWindow.Content = loginAdd;
            //childWindow.Content = new TTS();

            childWindow.WindowStartupLocation = Microsoft.Windows.Controls.WindowStartupLocation.Center;

            if (loginAdd.Height > 0)
            {
                childWindow.Height = loginAdd.Height + 40;
            }

            if (loginAdd.Width > 0)
            {
                childWindow.Width = loginAdd.Width;
            }
            childWindow.Show();

        }

        private void loginControl1_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}
